package com.example.studyktdemo.uitls;

import android.os.Handler;
import android.os.Looper;
import android.text.PrecomputedText;

import com.google.gson.Gson;

import java.util.concurrent.TimeUnit;

import okhttp3.OkHttpClient;

public class OkhttpClientManager {

    private static OkhttpClientManager mInstance;

    private OkHttpClient.Builder okHttpClient;
    private Handler mDelivery;
    private Gson mGson;

    public static OkhttpClientManager getInstance(){
        if (mInstance==null) {
            synchronized (OkhttpClientManager.class){
                if (mInstance==null){
                    mInstance = new OkhttpClientManager();
                }
            }
        }
        return mInstance;
    }

    private OkhttpClientManager(){
        okHttpClient = new OkHttpClient().newBuilder();
        //设置链接、读取、写入超时
        okHttpClient.connectTimeout(10, TimeUnit.SECONDS);
        okHttpClient.readTimeout(10, TimeUnit.SECONDS);
        okHttpClient.writeTimeout(10, TimeUnit.SECONDS);
        mDelivery = new Handler(Looper.getMainLooper());
        mGson = new Gson();
    }

    //public void postAsyn(String url, )
}
